﻿<UserControl x:Class="ModernUILogViewer.Content.ContentDateFormat"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:helper="clr-namespace:ModernUILogViewer.Elements.Helpers"
             xmlns:global="clr-namespace:System.Globalization;assembly=mscorlib"
             xmlns:view="clr-namespace:ModernUILogViewer.View"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"                
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"                
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <Grid >

        <DockPanel>

            <StackPanel DockPanel.Dock="Top">
                <TextBlock Text="INPUT DATE" Style="{StaticResource Heading2}" Margin="{StaticResource DefaultTopMargin}" />                
                <TextBox Text="{Binding InputDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="{StaticResource DefaultTopMargin}" 
                         helper:TextChangedCommandDelay.Command="{Binding ParseDate}"
                         helper:TextChangedCommandDelay.Delay="1.5"
                         />                       
                
                <Grid Margin="{StaticResource DefaultTopMargin}">
                    <Grid.RowDefinitions>
                        <RowDefinition></RowDefinition>
                        <RowDefinition></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="7*"></ColumnDefinition>
                        <ColumnDefinition Width="3*"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="DATE FORMAT" Style="{StaticResource Heading2}" Margin="{StaticResource DefaultTopMargin}" />
                    <TextBox x:Name="txtdateformat"  Text="{Binding DateFormat, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1"                          
                        DockPanel.Dock="Left"                        
                        helper:TextChangedCommandDelay.Command="{Binding ParseDate}"
                        helper:TextChangedCommandDelay.Delay="1.5"     
                    />
                    <TextBlock Text="CULTURE" Grid.Column="1" Style="{StaticResource Heading2}" Margin="{StaticResource DefaultTopMargin}" />
                    <ComboBox x:Name="comboCultures" ItemsSource="{Binding Source={StaticResource cultures}}" SelectedItem="{Binding SelectedCultureInfo, Mode=TwoWay}" Grid.Column="1" Grid.Row="1" />                        

                </Grid>

                <TextBlock Text="RESULT" Style="{StaticResource Heading2}" Margin="{StaticResource DefaultTopMargin}" />
                <TextBox IsReadOnly="True" Text="{Binding ParseResult}"  Margin="{StaticResource DefaultTopMargin}" />

                <StackPanel Orientation="Horizontal" Margin="0, 8, 0, 0" >
                    <TextBlock Text="MOST USED FORMATS" Style="{StaticResource Heading2}" />
                    <Button Command="{Binding AddToDateFormat}" CommandParameter="{Binding ElementName=comboFormat, Path=SelectedValue}" Width="50" Margin="{StaticResource DefaultLeftMargin}" >
                        <Path Width="16" Height="16" Stretch="Uniform" Fill="Black" Data="F1 M 34,57L 42,57L 42,32.25L 52,42.25L 52,31.75L 38,17.75L 24,31.75L 24,42.25L 34,32.25L 34,57 Z "/>
                    </Button>                                        
                </StackPanel>
            </StackPanel>

            <ListBox x:Name="comboFormat" VerticalAlignment="Top" DisplayMemberPath="Value" SelectedValuePath="Key" ItemsSource="{Binding DateFormatList, Mode=OneTime}" Margin="0, 8, 0, 0" DockPanel.Dock="Bottom" />

        </DockPanel>

        <i:Interaction.Triggers>
            <i:EventTrigger EventName="MouseDoubleClick" SourceObject="{Binding ElementName=comboFormat}">
                <i:InvokeCommandAction Command="{Binding AddToDateFormat}" CommandParameter="{Binding ElementName=comboFormat, Path=SelectedValue}" />
            </i:EventTrigger>
            <i:EventTrigger EventName="Loaded">
                <i:InvokeCommandAction Command="{Binding InitVM}" />
            </i:EventTrigger>
            <i:EventTrigger EventName="SelectionChanged" SourceObject="{Binding ElementName=comboCultures}">
                <i:InvokeCommandAction Command="{Binding ParseDate}" />
            </i:EventTrigger>
        </i:Interaction.Triggers>

    </Grid>
</UserControl>
